import pdfkit
import re
import urllib.request
import ssl
import uuid




ssl._create_default_https_context=ssl._create_unverified_context
# 构建代理Handler
httpproxy_handler = urllib.request.ProxyHandler(
    {
        "http": "192.168.84.249:8080",
        "https": "192.168.84.249:8080"
    },
)

def getHtml(url):
    opener = urllib.request.build_opener(httpproxy_handler)
    request = urllib.request.Request(url)
    page = opener.open(request)
    html = page.read()
    return html

if __name__ == '__main__':
    print("start")
    url = "http://localhost:9528/bar/#/login"
    config = pdfkit.configuration(wkhtmltopdf=r'E:\pytho-tool\wkhtmltox\bin\wkhtmltopdf.exe')
    print("kd")
    pdfkit.from_url(url, r'E:\pytho-tool\webphoto\local.pdf', configuration=config)
    # pdfkit.from_file(r"C:\Users\jamesony\Desktop\note\Python Urllib 批量下载页面图片 _ 包子文苑.html", r'E:\pytho-tool\webphoto\boke.pdf', configuration=config)
    print("end")
